/**
 * 添加或者修改页面
 */
var BasicOperateInfoDlg = {
    data: {
        operateName: "",
        operateContacts: "",
        operateTel: "",
        operateEmall: "",
        operateProvinces: "",
        operateCiywhere: "",
        operateBank: "",
        operateBankaccount: "",
        operateCreditcode: "",
        operateAddress: "",
        operateNotes: "",
        version: "",
        createTime: "",
        updateTime: "",
        createUser: "",
        updateUser: "",
        coId:"",
        coName:""
    }
};

/**
* 角色详情对话框
*/
var DeptInfoDlg = {
   data: {
       pid: "",
       pName: ""
   }
};

layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/basicOperate/addItem", function (data) {
            Feng.success("添加成功！");
            window.location.href = Feng.ctxPath + '/basicOperate'
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });


        /*$.ajax({
            url: Feng.ctxPath + "/sysCompany/list2",
            dataType: 'json',
            type: 'get',
            async:false,
            success: function (data) {
                console.log(data);
                //使用循环遍历，给下拉列表赋值
                var select = document.getElementById('coId');
                data.forEach(function (item) {
                    var option = document.createElement("option");
                    option.value = item.id; // 设置选项的值
                    option.text = item.coName;
                    select.add(option);
                });
                layui.form.render("select");
            }
        });*/

    // 点击上级角色时
    $('#deptName').click(function () {
        var formName = encodeURIComponent("parent.DeptInfoDlg.data.pName");
        var formId = encodeURIComponent("parent.DeptInfoDlg.data.pid");
        var treeUrl = encodeURIComponent("/dept/treeo");

        layer.open({
            type: 2,
            title: '父级部门',
            area: ['400px', '500px'],
            content: Feng.ctxPath + '/system/commonTree?formName=' + formName + "&formId=" + formId + "&treeUrl=" + treeUrl,
            end: function () {
                $("#deptId").val(DeptInfoDlg.data.pid);
                $("#deptName").val(DeptInfoDlg.data.pName);
            }
        });
    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/basicOperate'
    });

});